<template>
	<view class="content">
		<!--顶部标签-->
		<!-- <view class="content_1">
			<view class="tab_view">
				<view class="tab_box" @click="changeTab(1)">
					<view :class="choosetab == 1 ? 'tab_name' : 'tab_name_none'">类型</view>
					<image class="tab_icon" src="../../../static/mine/downjiantou.svg"></image>
				</view>
				<view class="tab_box" @click="changeTab(2)">
					<view :class="choosetab == 2 ? 'tab_name' : 'tab_name_none'">年份</view>
					<image class="tab_icon" src="../../../static/mine/downjiantou.svg"></image>
				</view>
				<view class="tab_box" @click="changeTab(3)">
					<view :class="choosetab == 3 ? 'tab_name' : 'tab_name_none'">月份</view>
					<image class="tab_icon" src="../../../static/mine/downjiantou.svg"></image>
				</view>
			</view>
		</view> -->
		<!--账单详细-->
		<view class="content_2">
			<block v-for="(data, index) in orderList" :key='index'>
				<view class="order_view">
					<view class="line_2"></view>
					<!-- <view class="order_box">
						<view class="detail_name">交易金额</view>
						<view class="detail" style="color: #63D0D5;">{{item_order.pay_money}}</view>
					</view> -->
					<!-- <view class="order_box">
						<view class="detail_name">交易类型</view>
						<view class="detail">{{item_order.bill_type}}</view>
					</view> -->
					<view class="order_box">
						<view class="detail_name">发布时间</view>
						<view class="detail">{{data.time}}</view>
					</view>
					<view class="order_box">
						<view class="detail_name">信息编号</view>
						<view class="detail">{{data.order_sn}}</view>
					</view>
					<view class="order_box">
						<view class="detail_name">备注</view>
						<view class="detail">{{data.text}}</view>
					</view>
					<view class="operate_button">
						<view class="operate_edit" @click="edit(index, 'orderList')">编辑</view>
						<view class="operate_del" @click="del(index, 'orderList')">删除</view>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	import {Request} from '../../../utils/request.js';
	const app = getApp();
	export default {
		data() {
			return {
				choosetab: '1',
				orderList: [],
				//排序状态
				sortstate: '0',
			}
		},
		methods: {
			//删除信息
			del: function(index, arr){
				let PushId = this[arr][index].id;
				//删除发布信息
				new Request('customer/push/Get_Push_List/PushDel').request(
					()=>{
						return 'POST'
					},
					()=>{
						return {
							openid: app.globalData.openid,
							push_id: PushId,
						}
					},
					(res)=>{
						if(res.data.code == 1){
							new Request().showToast('删除成功', 'success', ()=>{
								this.show();
							});							
						}
					}
				);
			},
			//跳转编辑页面
			edit: function(index, arr){
				let PushId = this[arr][index].id;
				uni.navigateTo({
				    url: '/pages/mine/push/edit/edit?push_id=' + PushId,
				});
			},
			//升序方法
			compare: function(property) {
				console.log(property)
				return function(a, b) {
					var value1 = a[property];
					var value2 = b[property];
					return value1 - value2;
				}
			},
			//降序方法
			uncompare: function(property) {
				return function(a, b) {
					var value1 = a[property];
					var value2 = b[property];
					return value2 - value1;
				}
			},
			//tab切换
			changeTab: function(id) {
				this.choosetab = id
				if(id == 2) {
					if (this.sortstate == '0') {
						this.orderList.sort(this.compare('year'))
						this.sortstate = '1'
					} else {
						this.orderList.sort(this.uncompare('year'))
						this.sortstate = '0'
					}
				}
				if (id == 3) {
					if (this.sortstate == '0') {
						this.orderList.sort(this.compare('month'))
						this.sortstate = '1'
					} else {
						this.orderList.sort(this.uncompare('month'))
						this.sortstate = '0'
					}
				}
			},
			show:function(){
				//获取发布信息列表
				new Request('customer/push/Get_Push_List/GetCustomerPushList').request(
					()=>{
						return 'POST'
					},
					()=>{
						return {
							openid: app.globalData.openid,
							
						}
					},
					(res)=>{
						if(res.data.code == 0){
							new Request().showToast(res.data.msg);
							return;
						}
						if (res.data.code == 1) {
							this.orderList = res.data.data
							this.orderList = this.orderList.map((item, index) =>{
								return {
									id: item.id,
									time: item.time,
									order_sn: item.createtime,
									text: item.text == '' ? '无' : item.text,
									// month: item.paytime.slice(5,7),
									// year: item.paytime.slice(0,4)
								}
							})
							console.log(this.orderList)
						}
					}
				)
			}
		},
		onLoad() {
		},
		onShow(){
			this.show();
		}
	}
</script>

<style>
	page {
		background-color: #F9F9F9;
	}

	.content {
		padding-bottom: 190upx;
	}

	/*
		顶部标签样式
	*/
	.content_1 {
		margin-top: 40upx;
		padding-left: 40upx;
	}

	.tab_view {
		height: 40upx;
		display: flex;
		align-items: center;
	}

	.tab_box {
		height: 40upx;
		display: flex;
		align-items: center;
		margin-right: 80upx;
	}

	.tab_name {
		height: 40upx;
		line-height: 40upx;
		font-size: 28upx;
		color: #B3E9DC;
		margin-right: 10upx;
	}

	.tab_name_none {
		height: 40upx;
		line-height: 40upx;
		font-size: 28upx;
		color: #666666;
		margin-right: 10upx;
	}

	.tab_icon {
		height: 28upx;
		width: 28upx;
	}

	/**
	 * 账单详细样式
	 */

	.order_view {
		margin-top: 30upx;
		display: flex;
		flex-direction: column;
	}

	.line_2 {
		height: 20upx;
		background-color: #FFFFFF;
		margin-bottom: 20upx;
	}

	.order_box {
		height: 80upx;
		padding: 0upx 40upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.detail_name {
		height: 80upx;
		line-height: 80upx;
		font-size: 28upx;
		color: #999999;
	}

	.detail {
		height: 80upx;
		line-height: 80upx;
		font-size: 28upx;
		color: #999999;
	}
	/* 操作按钮 */
	.operate_button{
		display: flex;
		justify-content: flex-end;
		font-size: 28upx;
		padding: 0upx 40upx;
	}
	.operate_edit{
		color: orange;
		margin: 10upx;
	}
	.operate_del{
		color: red;
		margin: 10upx 0 10upx 10upx;
	}
</style>
